package com.cszy.yydqbfq.adapter

import android.content.Context
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.cszy.yydqbfq.R

import com.cszy.yydqbfq.utils.SpUtils
import com.hlyj.http.base.tool.lib_hlyj_base.bean.music.MusicListBean
import com.hlyj.http.base.tool.lib_hlyj_base.utils.BaseAppConstans


class IndexListJingXuanAdapter:BaseQuickAdapter<MusicListBean,QuickViewHolder>() {
    var  app_process = SpUtils.getInstance().getString(BaseAppConstans.APP_PROCESS)
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: MusicListBean?) {
        if (app_process=="0"){
            holder.setText(R.id.tv_music_name,item?.alias)
        }else{
            holder.setText(R.id.tv_music_name,item?.name)
        }

        holder.setText(R.id.tv_author, item?.author ?: "未知")
        Glide.with(context)
            .load(item?.imageUrl)
            .placeholder(R.mipmap.ic_default)
            .error(R.mipmap.ic_default)
            .apply(RequestOptions.circleCropTransform()) // 关键代码：圆形裁剪
            .into(holder.getView(R.id.iv_music_cover))

    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_index_jingxuan_list, parent)
    }
}